import { IPSDataEntity } from '../ipsdata-entity';
import { IPSDEMap } from './ipsdemap';
import { IPSDEMapDataQuery } from './ipsdemap-data-query';
import { IPSDEDataQuery } from '../ds/ipsdedata-query';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEMapDataQueryImpl extends PSModelObjectImpl implements IPSDEMapDataQuery {
  get codeName(): string {
    return this.M.codeName;
  }

  protected dstpsdedataquery: IPSDEDataQuery | null = null;

  getDstPSDEDataQuery(): IPSDEDataQuery | null {
    if (this.dstpsdedataquery != null) return this.dstpsdedataquery;
    const value = this.M.getDstPSDEDataQuery;
    if (value == null) {
      return null;
    }
    const ipsdemap = this.getParentPSModelObject('dataentity.datamap.IPSDEMap') as IPSDEMap;
    if (ipsdemap != null) {
      this.dstpsdedataquery = ipsdemap.getDstPSDEMust().findPSDEDataQuery(value);
    }
    return this.dstpsdedataquery;
  }

  get dstPSDEDataQuery(): IPSDEDataQuery | null {
    return this.getDstPSDEDataQuery();
  }

  getDstPSDEDataQueryMust(): IPSDEDataQuery {
    const value = this.getDstPSDEDataQuery();
    if (value == null) {
      throw new Error('未指定目标实体查询');
    }
    return value;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get mapMode(): 'DEFAULT' | 'INNER' {
    return this.M.mapMode || 'DEFAULT';
  }

  get mapParams(): IModel {
    return this.M.mapParams;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected srcpsdedataquery: IPSDEDataQuery | null = null;

  getSrcPSDEDataQuery(): IPSDEDataQuery | null {
    if (this.srcpsdedataquery != null) return this.srcpsdedataquery;
    const value = this.M.getSrcPSDEDataQuery;
    if (value == null) {
      return null;
    }
    const ipsdataentity = this.getParentPSModelObject('dataentity.IPSDataEntity') as IPSDataEntity;
    if (ipsdataentity != null) {
      this.srcpsdedataquery = ipsdataentity.findPSDEDataQuery(value);
    }
    return this.srcpsdedataquery;
  }

  get srcPSDEDataQuery(): IPSDEDataQuery | null {
    return this.getSrcPSDEDataQuery();
  }

  getSrcPSDEDataQueryMust(): IPSDEDataQuery {
    const value = this.getSrcPSDEDataQuery();
    if (value == null) {
      throw new Error('未指定源实体查询');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get cls(): string {
    return 'PSDEMapDataQueryImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.datamap.IPSDEMapDataQuery') return true;
    return super.instanceof(cls);
  }
}
